<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>账号展示</title>
	<%@ include file="/view/common/tags.jsp"%>
	<script type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"> </script>
</head>
<body>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                       <div class="panel panel-default">
                            <div class="panel-body" style="padding-bottom:5px;">
                            	<input id="sourceListJson" type="hidden" value="${sourceListJson}" >
                            	<input id="gameNameListJson" type="hidden" value="${gameNameListJson}" >
                                <form class="form-horizontal" action="" method="post" id="dataForm">
                                	<input type="hidden" id="token" name="token" value=""/>
                                	<div class="searchMenu">
                                	    <div>
	                                  	    <label>平台：</label>
	                                   		<sk:select cssClass="form-control select" name="platformType" id="platformType" value="" requiredInit="true" ajaxURL="${sysManagerV1}/baseType/select?wm[PARENT_ID]=20">
                                                <option value="">请选择</option>
                                            </sk:select>
	                                    </div>
	                                    <div>
                                		    <label>帐号：</label>
                                            <input type="text" class="form-control" name="wm[_LIKE$USER_NAME]" value="${page.wm._LIKE$USER_NAME}"  placeholder="请输入帐号">
                                        </div>
	                                    <div class="mal10" >
	                                        <button type="button"  class="btn btn-primary btn-sm"  onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
	                                    </div>
                                	</div>
                                </form>
                            </div>
                        </div>
                        <table class="table table-hover table-condensed table-bordered table-striped" id="dataTable" >
                            <thead>
                                <tr>
                                	<th data-field="index" data-align="center" data-formatter="indexFormatter" data-sortable="false">序号</th>
                                    <th data-field="platformType" data-align="center"  data-sortable="false" data-formatter="platformTypeFormatter">平台</th>
                                    <th data-field="userName" data-align="center"  data-sortable="false">账号</th>
                                    <th data-field="emailPwd" data-align="center"  data-sortable="false">邮箱密码</th>
                                    <th data-field="loginPwd" data-align="center" data-sortable="false">网站密码</th>
                                    <th data-field="payPwd" data-align="center" data-sortable="false">支付密码</th>
                                    <th data-field="createTime" data-align="center" data-sortable="false">分配时间</th>
                                    <th data-field="optButton" data-align="center" data-sortable="false" data-formatter="buttonFormatter">操作</th> 
                                </tr>
                            </thead>
                        </table>
                   	</div>
            	</div>
           	</div>
		</div>
    </section>
   <%@ include file="/view/common/footer.jsp"%>
</body>
<script>
//操作按钮
function buttonFormatter(value, row,index) {
    var e = "<button id='btn_edit' type='button' onclick='getCode("+row.rowId+","+row.platformType+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>提取验证码</button>";
    var f = "<button id='btn_edit' type='button' onclick='submitResult("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>提交</button>";
    return e + "&nbsp;" + f ;
}

// 获取谷歌验证码
function getCode(rowId,platformType){
	var token = $("#token").val();
            if (rowId == null || rowId == "") {
                layer.msg("id不能为空!");
                return;
            }
            $.post(JSSYSMANAGERV1 + "/cardUser/getGoogleCode?rowId="+rowId+"&token="+token+"&platformType="+platformType,null,function(json){
                if (json.code == 0) {
                    layer.alert("<span style='color:red;'>"+json.data +"</span>", {icon: 1});
                } else {
                    layer.msg("失败", {icon: 5});
                } 
            });
}

var index = 0;
//提交操作结果
function submitResult(rowId) {
    if (rowId != null && rowId > 0) {
        index = layer.open({
            type: 2,
            title: "提交结果",
            closeBtn: 1,
            shadeClose: true,
            area: ['500px', '500px'],
            content: JSSYSMANAGERV1 + '/kfManage/toSumbit?rowId=' + rowId ,
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.submitResult();
            }
        });
    }
}


// 加载table 数据
$(function(){
	 $("#token").val(sessionStorage.getItem("token"));
	 
    $("#dataTable").bootstrapTable({ 
    	url: "${sysManagerV1}/cardOptRecord/data",
    	method:"get", 
    	pagination:true,
    	sidePagination:"server",
    	queryParams: function(params) {
            return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));     
        }
   }); 
 })

// 平台名称格式化
function platformTypeFormatter(value, row, index) {
	var html = "启用";
	$("#platformType option").each(function(){  //遍历所有option    
        var val= $(this).val();   //获取option值     
        if(val == value){    
            html = $(this).text();
            return;
        }    
   });  
   return html;
}

//查询
function findData(){
    $("#dataTable").bootstrapTable("refresh",{} );
}

var tableIndex = 0;
// 弹出添加的窗口
function add(){
    tableIndex = layer.open({
        type: 2,
        title: "添加账号",
        closeBtn: 1,
        shadeClose: true,
        area: ['420px', '400px'],
        content: '/accountManage/toAdd?rowId=0',
        btn: ["确 认","关 闭"],
        yes: function(index, layero){
            var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
            iframeWin.add();
        }
    });
}

// 提示信息
var msgg='<%=request.getAttribute("msg")%>';
if( msgg && msgg!=null && msgg!='null'){ 
	  layer.msg(msgg);
}
</script>
</html>